import { IPSApplication } from '../../app/ipsapplication';
import { IPSAppFunc } from '../../app/func/ipsapp-func';
import { IPSControlAttribute } from '../ipscontrol-attribute';
import { IPSControlLogic } from '../ipscontrol-logic';
import { IPSControlRender } from '../ipscontrol-render';
import { IPSNavigateContext } from '../ipsnavigate-context';
import { IPSNavigateParam } from '../ipsnavigate-param';
import { IPSLayout } from '../layout/ipslayout';
import { IPSLayoutPos } from '../layout/ipslayout-pos';
import { IPSAppMenuItem } from './ipsapp-menu-item';
import { IPSLanguageRes } from '../../res/ipslanguage-res';
import { IPSSysCss } from '../../res/ipssys-css';
import { IPSSysImage } from '../../res/ipssys-image';
import { IPSSysPFPlugin } from '../../res/ipssys-pfplugin';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppMenuItemImplBase extends PSModelObjectImpl implements IPSAppMenuItem {
  get accUserMode(): 0 | 2 | 3 | 4 {
    return this.M.accUserMode;
  }

  get accessKey(): string {
    return this.M.accessKey;
  }

  get appMenuItemState(): 1 | 2 {
    return this.M.appMenuItemState != null ? this.M.appMenuItemState : 0;
  }

  protected cappslanguageres: IPSLanguageRes | null = null;

  getCapPSLanguageRes(): IPSLanguageRes | null {
    if (this.cappslanguageres != null) return this.cappslanguageres;
    const value = this.M.getCapPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.cappslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getCapPSLanguageRes') as IPSLanguageRes;
    return this.cappslanguageres;
  }

  get capPSLanguageRes(): IPSLanguageRes | null {
    return this.getCapPSLanguageRes();
  }

  getCapPSLanguageResMust(): IPSLanguageRes {
    const value = this.getCapPSLanguageRes();
    if (value == null) {
      throw new Error('未指定标题语言资源');
    }
    return value;
  }

  get caption(): string {
    return this.M.caption;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get counterId(): string {
    return this.M.counterId;
  }

  get cssStyle(): string {
    return this.M.cssStyle;
  }

  get data(): string {
    return this.M.data;
  }

  get dynaClass(): string {
    return this.M.dynaClass;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get informTag(): string {
    return this.M.informTag;
  }

  get informTag2(): string {
    return this.M.informTag2;
  }

  get itemType(): 'SEPERATOR' | 'USERITEM' | 'APPMENUREF' | 'MENUITEM' | 'RAWITEM' {
    return this.M.itemType;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psappfunc: IPSAppFunc | null = null;

  getPSAppFunc(): IPSAppFunc | null {
    if (this.psappfunc != null) return this.psappfunc;
    const value = this.M.getPSAppFunc;
    if (value == null) {
      return null;
    }
    const ipsapplication = this.getParentPSModelObject('app.IPSApplication') as IPSApplication;
    if (ipsapplication != null) {
      this.psappfunc = ipsapplication.findPSAppFunc(value);
    }
    return this.psappfunc;
  }

  get psAppFunc(): IPSAppFunc | null {
    return this.getPSAppFunc();
  }

  getPSAppFuncMust(): IPSAppFunc {
    const value = this.getPSAppFunc();
    if (value == null) {
      throw new Error('未指定应用功能');
    }
    return value;
  }

  protected psappmenuitems: IPSAppMenuItem[] | null = null;

  getPSAppMenuItems(): IPSAppMenuItem[] | null {
    if (this.psappmenuitems == null) {
      this.psappmenuitems = this.fillChildListModel(this.M.getPSAppMenuItems, 'control.menu.IPSAppMenuItem') as IPSAppMenuItem[];
    }
    return this.psappmenuitems;
  }

  get psAppMenuItems(): IPSAppMenuItem[] | null {
    return this.getPSAppMenuItems();
  }

  findPSAppMenuItem(objKey: any): IPSAppMenuItem | null {
    return this.getPSModel5('control.menu.IPSAppMenuItem', this.getPSAppMenuItems(), objKey) as IPSAppMenuItem;
  }

  protected pscontrolattributes: IPSControlAttribute[] | null = null;

  getPSControlAttributes(): IPSControlAttribute[] | null {
    if (this.pscontrolattributes == null) {
      this.pscontrolattributes = this.fillChildListModel(this.M.getPSControlAttributes, 'control.IPSControlAttribute') as IPSControlAttribute[];
    }
    return this.pscontrolattributes;
  }

  get psControlAttributes(): IPSControlAttribute[] | null {
    return this.getPSControlAttributes();
  }

  findPSControlAttribute(objKey: any): IPSControlAttribute | null {
    return this.getPSModel5('control.IPSControlAttribute', this.getPSControlAttributes(), objKey) as IPSControlAttribute;
  }

  protected pscontrollogics: IPSControlLogic[] | null = null;

  getPSControlLogics(): IPSControlLogic[] | null {
    if (this.pscontrollogics == null) {
      this.pscontrollogics = this.fillChildListModel(this.M.getPSControlLogics, 'control.IPSControlLogic') as IPSControlLogic[];
    }
    return this.pscontrollogics;
  }

  get psControlLogics(): IPSControlLogic[] | null {
    return this.getPSControlLogics();
  }

  findPSControlLogic(objKey: any): IPSControlLogic | null {
    return this.getPSModel5('control.IPSControlLogic', this.getPSControlLogics(), objKey) as IPSControlLogic;
  }

  protected pscontrolrenders: IPSControlRender[] | null = null;

  getPSControlRenders(): IPSControlRender[] | null {
    if (this.pscontrolrenders == null) {
      this.pscontrolrenders = this.fillChildListModel(this.M.getPSControlRenders, 'control.IPSControlRender') as IPSControlRender[];
    }
    return this.pscontrolrenders;
  }

  get psControlRenders(): IPSControlRender[] | null {
    return this.getPSControlRenders();
  }

  findPSControlRender(objKey: any): IPSControlRender | null {
    return this.getPSModel5('control.IPSControlRender', this.getPSControlRenders(), objKey) as IPSControlRender;
  }

  protected pslayout: IPSLayout | null = null;

  getPSLayout(): IPSLayout | null {
    if (this.pslayout != null) return this.pslayout;
    const value = this.M.getPSLayout;
    if (value == null) {
      return null;
    }
    this.pslayout = this.getPSModel4('control.layout.IPSLayout', value, 'getPSLayout') as IPSLayout;
    return this.pslayout;
  }

  get psLayout(): IPSLayout | null {
    return this.getPSLayout();
  }

  getPSLayoutMust(): IPSLayout {
    const value = this.getPSLayout();
    if (value == null) {
      throw new Error('未指定布局设置');
    }
    return value;
  }

  protected pslayoutpos: IPSLayoutPos | null = null;

  getPSLayoutPos(): IPSLayoutPos | null {
    if (this.pslayoutpos != null) return this.pslayoutpos;
    const value = this.M.getPSLayoutPos;
    if (value == null) {
      return null;
    }
    this.pslayoutpos = this.getPSModel4('control.layout.IPSLayoutPos', value, 'getPSLayoutPos') as IPSLayoutPos;
    return this.pslayoutpos;
  }

  get psLayoutPos(): IPSLayoutPos | null {
    return this.getPSLayoutPos();
  }

  getPSLayoutPosMust(): IPSLayoutPos {
    const value = this.getPSLayoutPos();
    if (value == null) {
      throw new Error('未指定位置');
    }
    return value;
  }

  protected psnavigatecontexts: IPSNavigateContext[] | null = null;

  getPSNavigateContexts(): IPSNavigateContext[] | null {
    if (this.psnavigatecontexts == null) {
      this.psnavigatecontexts = this.fillChildListModel(this.M.getPSNavigateContexts, 'control.IPSNavigateContext') as IPSNavigateContext[];
    }
    return this.psnavigatecontexts;
  }

  get psNavigateContexts(): IPSNavigateContext[] | null {
    return this.getPSNavigateContexts();
  }

  findPSNavigateContext(objKey: any): IPSNavigateContext | null {
    return this.getPSModel5('control.IPSNavigateContext', this.getPSNavigateContexts(), objKey) as IPSNavigateContext;
  }

  protected psnavigateparams: IPSNavigateParam[] | null = null;

  getPSNavigateParams(): IPSNavigateParam[] | null {
    if (this.psnavigateparams == null) {
      this.psnavigateparams = this.fillChildListModel(this.M.getPSNavigateParams, 'control.IPSNavigateParam') as IPSNavigateParam[];
    }
    return this.psnavigateparams;
  }

  get psNavigateParams(): IPSNavigateParam[] | null {
    return this.getPSNavigateParams();
  }

  findPSNavigateParam(objKey: any): IPSNavigateParam | null {
    return this.getPSModel5('control.IPSNavigateParam', this.getPSNavigateParams(), objKey) as IPSNavigateParam;
  }

  protected pssyscss: IPSSysCss | null = null;

  getPSSysCss(): IPSSysCss | null {
    if (this.pssyscss != null) return this.pssyscss;
    const value = this.M.getPSSysCss;
    if (value == null) {
      return null;
    }
    this.pssyscss = this.getPSModel4('res.IPSSysCss', value, 'getPSSysCss') as IPSSysCss;
    return this.pssyscss;
  }

  get psSysCss(): IPSSysCss | null {
    return this.getPSSysCss();
  }

  getPSSysCssMust(): IPSSysCss {
    const value = this.getPSSysCss();
    if (value == null) {
      throw new Error('未指定系统样式表');
    }
    return value;
  }

  protected pssysimage: IPSSysImage | null = null;

  getPSSysImage(): IPSSysImage | null {
    if (this.pssysimage != null) return this.pssysimage;
    const value = this.M.getPSSysImage;
    if (value == null) {
      return null;
    }
    this.pssysimage = this.getPSModel4('res.IPSSysImage', value, 'getPSSysImage') as IPSSysImage;
    return this.pssysimage;
  }

  get psSysImage(): IPSSysImage | null {
    return this.getPSSysImage();
  }

  getPSSysImageMust(): IPSSysImage {
    const value = this.getPSSysImage();
    if (value == null) {
      throw new Error('未指定系统图片');
    }
    return value;
  }

  protected pssyspfplugin: IPSSysPFPlugin | null = null;

  getPSSysPFPlugin(): IPSSysPFPlugin | null {
    if (this.pssyspfplugin != null) return this.pssyspfplugin;
    const value = this.M.getPSSysPFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyspfplugin = this.getPSModel4('res.IPSSysPFPlugin', value, 'getPSSysPFPlugin') as IPSSysPFPlugin;
    return this.pssyspfplugin;
  }

  get psSysPFPlugin(): IPSSysPFPlugin | null {
    return this.getPSSysPFPlugin();
  }

  getPSSysPFPluginMust(): IPSSysPFPlugin {
    const value = this.getPSSysPFPlugin();
    if (value == null) {
      throw new Error('未指定前端应用插件');
    }
    return value;
  }

  get titleBarCloseMode(): 0 | 1 | 2 {
    return this.M.titleBarCloseMode != null ? this.M.titleBarCloseMode : 0;
  }

  get tooltip(): string {
    return this.M.tooltip;
  }

  protected tooltippslanguageres: IPSLanguageRes | null = null;

  getTooltipPSLanguageRes(): IPSLanguageRes | null {
    if (this.tooltippslanguageres != null) return this.tooltippslanguageres;
    const value = this.M.getTooltipPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.tooltippslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getTooltipPSLanguageRes') as IPSLanguageRes;
    return this.tooltippslanguageres;
  }

  get tooltipPSLanguageRes(): IPSLanguageRes | null {
    return this.getTooltipPSLanguageRes();
  }

  getTooltipPSLanguageResMust(): IPSLanguageRes {
    const value = this.getTooltipPSLanguageRes();
    if (value == null) {
      throw new Error('未指定操作提示语言资源');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get disableClose(): boolean {
    return this.M.disableClose != null ? this.M.disableClose : false;
  }

  get expanded(): boolean {
    return this.M.expanded != null ? this.M.expanded : false;
  }

  get hidden(): boolean {
    return this.M.hidden != null ? this.M.hidden : false;
  }

  get hideSideBar(): boolean {
    return this.M.hideSideBar != null ? this.M.hideSideBar : false;
  }

  get openDefault(): boolean {
    return this.M.openDefault != null ? this.M.openDefault : false;
  }

  get seperator(): boolean {
    return this.M.seperator != null ? this.M.seperator : false;
  }

  get valid(): boolean {
    return this.M.valid != null ? this.M.valid : true;
  }

  get cls(): string {
    return 'PSAppMenuItemImplBase';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.IPSNavigateParamContainer' || cls == 'control.layout.IPSLayoutContainer' || cls == 'control.layout.IPSLayoutItem' || cls == 'control.menu.IPSAppMenuItem') return true;
    return super.instanceof(cls);
  }
}
